<?php
namespace app\common\model;
use x\Xbase;
class UserThree extends Xbase
{
    /**
     * 同步第三方openid，即临时推荐关系
     * @param  integer $type      [description]
     * @param  [type]  $openid    [description]
     * @param  [type]  $s_user_id [description]
     * @param  [type]  $s_openid  [description]
     * @return [type]             [description]
     */
    public function edit($type=0,$openid){

        $rs = $this->db->query("select * from user_three where openid=? and type=?",[$openid,$type],1);
        if ($rs) return $rs[''];

        $data = [
            'type' => $type,
            'openid' => $openid,
            'create_time' => time()
        ];
        $id = $this->db->insert("user_three",$data);
        if(!$id) return $this->setError('同步错误!');

        return true;
    }

}
